// 列表的颜色变化
var inquireTbody = document.getElementsByClassName('inquireTbody')[0];
console.log(inquireTbody.children[0]);
for(var i = 0;i < inquireTbody.children.length;i++){
    if(i%2==0){
        inquireTbody.children[i].style.backgroundColor="white";
    }else{
        inquireTbody.children[i].style.backgroundColor="rgba(0,0,0,.02)";
    }
}

//分页查询
var prePage=document.getElementsByClassName('prePage')[0];
var nextPage=document.getElementsByClassName('nextPage')[0];
var page=1;
var toPage=document.getElementsByClassName('toPage')[0];
var allPage=document.getElementsByClassName('allPage')[0].innerHTML
var toFirst=document.getElementsByClassName('toFirst')[0];
var toLast=document.getElementsByClassName('toLast')[0];
toFirst.onclick=function () {
    // location.href = 'http://localhost:8080/future/music/allMusic?page=1';
}
toLast.onclick=function (){
    // location.href = 'http://localhost:8080/future/music/allMusic?page='+allPage;
}
prePage.onclick=function(){
    if(toPage.value<=1){
        alert("已经首页");
        return;
    }else{
        page=toPage.value-1;
        location.href = 'http://localhost:8080/future/music/allMusic?page='+page;
    }

}
nextPage.onclick=function(){
    console.log(allPage);
    var pagenum = allPage;
    if(Number(toPage.value)>=pagenum){
        alert("见底了");
        return;
    }else{
        page=Number(toPage.value)+1;
        location.href = 'http://localhost:8080/future/music/allMusic?page='+page;
        console.log(page);
    }
}

//更改页码框中的值
toPage.onkeydown=function(event) {
    var event = event;
    if (event.keyCode == 13) {
        location.href = 'http://localhost:8080/future/music/allMusic?page=' + Number(toPage.value);
    }
}